package com.example.add;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

//import android.support.v7.app.AppCompatActivity;
//import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private TextView tv1,tv2;
    private EditText edt1,edt2;
    private Button btn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn=(Button)this.findViewById(R.id.btn);
        edt1=(EditText)this.findViewById(R.id.edit1);
        edt2=(EditText)this.findViewById(R.id.edit2);
        tv1=(TextView)this.findViewById(R.id.text1);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String inputText1=edt1.getText().toString();
                String inputText2=edt2.getText().toString();
                int num1=Integer.valueOf(inputText1).intValue();
                int num2=Integer.valueOf(inputText2).intValue();
                num1=num1+num2;
                inputText1=String.valueOf(num1);
                tv1.setText(inputText1);
            }
        });
    }
}